//
//  TMShopListCell.m
//  国学商家管理
//
//  Created by Tao Li on 2018/6/29.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMShopListCell.h"
#import "TMMyCourseModel.h"
@implementation TMShopListCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.checkListBtn.hidden = NO;
    self.leftConst.constant = 42;
    self.courseImageView.contentMode = UIViewContentModeScaleAspectFill;
    self.courseImageView.clipsToBounds = YES;
    self.addView.hidden = YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (IBAction)checkListBtnAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (self.checkBlock) {
        self.checkBlock(sender.selected);
    }
}
- (IBAction)cutBtnAction:(UIButton *)sender {
    NSInteger couns = [[NSString stringWithFormat:@"%@", self.itemNumLabel.text] integerValue];
    if (couns == 0) {
        return;
    }
    if (self.cutBlock) {
        self.cutBlock(couns);
    }
}
- (IBAction)addBtnAction:(UIButton *)sender {
    NSInteger couns = [[NSString stringWithFormat:@"%@", self.itemNumLabel.text] integerValue];
    if (self.addBlock) {
        self.addBlock(couns);
    }
}
- (void)setModel:(TMMyCartModel *)model{
    _model = model;
    self.courseName.text = model.name;
    self.teacherLabel.text = [NSString stringWithFormat:@"任课老师:%@", model.tea_name];
    if (model.rank >1) {
       self.priceLabel.text = [NSString stringWithFormat:@"¥%.02f", model.agio_price];
    }else{
    self.priceLabel.text = [NSString stringWithFormat:@"¥%.02f", model.price];
    }
    if (model.under.integerValue == 0) {
        self.priceLabel.text = [NSString stringWithFormat:@"商品已下架"];
    }
    [self.courseImageView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithBaseUrl:model.pic[0]]] placeholderImage:kPlaceholder];
    self.itemNumLabel.text = [NSString stringWithFormat:@"%ld",model.num];
}
@end
